<?php

/**
 * Framework_Presenter_XmlRpc
 *
 * @author Application Support Group
 * @copyright University of Georgia
 * @package BAMF
 * @filesource
 */

require_once 'XML/RPC/Server.php' ;

/**
 * Framework_Presenter_XmlRpc
 *
 * Use this presenter in the context of an XML-RPC server.
 *
 * @author Application Support Group
 * @package BAMF
 */
class Framework_Presenter_XmlRpc extends Framework_Presenter_Common
{

	private $_dispatchMap = array();
	private $otherData = array();
	
    /**
     * __construct
     *
     * @author Application Support Group
     * @access public
     * @param mixed $module Instance of Framework_Module
     * @return void
     */
    public function __construct(Framework_Module $module)
    {
        parent::__construct($module);
    }

    /**
     * display
     *
     * 
     * 
     * @author Application Support Group
     * @return void
     * @link http://pear.php.net/package/XML_RPC
     */
    public function display()
    {
		foreach ($this->module->getData() as $var => $val) {
			if ($var{0} == "_") {
				$this->$var = $val ;
			} else {
				$this->otherData[$var] = $val ;
			}				
		}

		/*
		 *
		 *	Can also add second argument zero to delay the response and send
		 *	it manually with $server->service(). This might give us an
		 *	opportunity to muck around with the data in the server object,
		 *	if we wanted to do so...
		 * 
		 */

		if (!empty($this->_dispatchMap)) {
			$server = new XML_RPC_Server($this->_dispatchMap);
		} else {
			return Framework_ErrorHandler::raiseError( "Error: No _dispatchMap for XML-RPC call.", __METHOD__."::".__LINE__ ) ;
		}

    }

    public function __destruct()
    {
        parent::__destruct();
    }
}

?>
